-
Notifications
You must be signed in to change notification settings - Fork 16.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AP_NavEKF2: switch to optflow if gps is jammed #12482
Conversation
f40222a
to
71f83a1
Compare
Thanks for tagging me in #11156. This seems to handle the third failure case I described in that issue. Still learning the code, so forgive my questions: Where does it switch back to using GPS when it becomes available again? Is this handled by
Why do we check if optiflow is available if |
Hi @RickReeser
I think it is here, switch from AID_RELATIVE to AID_ABSOLUTE ardupilot/libraries/AP_NavEKF2/AP_NavEKF2_Control.cpp Lines 187 to 188 in 71f83a1
In current code, it did not set PV_AidingMode = AID_NONE if posAidLossCritical ardupilot/libraries/AP_NavEKF2/AP_NavEKF2_Control.cpp Lines 252 to 254 in 9456fe4
I think there is a reason, but I do not know. I think it may be better to not to change original logic too much. Hi @priseborough Could you possibly take a look at this? Thank you very much @RickReeser Would you be able to test it? I build a firmware for pixhawk2 cubeblack from this PR |
Could you please add EKF3 support too? |
@chobitsfan I'll get a chance to test this tomorrow or next week. Does that binary include your other PR #12481? Looks like it was merged 1 day before you commented. |
@Jaaaky I think it may be better to waiting for @priseborough to review it in EKF2 first?
@RickReeser Yes. thank you very much for helping |
hi @RickReeser may I ask how is your tests going? Is everything OK? Thank you very much. |
Unfortunately I had to put my test on hold for a while due to some very frustrating reasons, but hopefully I should be able to do it within the next week. I backported your PRs and will be testing them on 3.6.12. |
Thank you @RickReeser |
Just letting you know I haven't forgotten, I just keep running into roablocks. Will test this as soon as I can... Edit: Finally got to do some testing, only to discover that the jammer is burned out. Need to order a new one. |
I just ran across this PR again. It's still valuable and we should try and get it in soon-ish. non-GPS navigation is climbing on my to-do list. |
Thank you @rmackay9 |
Finally, after much ado, I was able to test fly these changes. I backported these PRs to Copter 3.6.12, so I flew 3.6.12 official as the baseline comparison. In these tests, I slowly descended the drone into the influence of a jammer near the ground. I set My results are the same as @chobitsfan's. In the official firmware, the EKF failsafes into land mode when the GPS position times out. With this PR, it switches to optiflow as intended. Copter 3.6.12 with these changes: logs: |
@RickReeser Thank you so much for helping testing Did your copter hold well after it switch from GPS to optical flow? Did it shift a little after switch back to GPS (after GPS jammer turned off)? |
I've tested this in the simulator and it seems fine. The steps I used to test it were:
@priseborough, @tridge, what do you think about this change? it looks fairly straight forward to me and seems to work. EDIT: one thing I noticed is that if I disabled the flow sensor by setting FLOW_TYPE = 0 while the GPS was also disabled, the vehicle's position would jump a long way off. My guess is that this is unrelated though and that same odd position is reported by the EKF when GPS_TYPE = 0 regardless of the changes in this PR. I think this odd position stems from the EKF continuing to apply the last know velocities that it got to the position. So if it was flying at 1m/s when it lost GPS it continues to apply that 1m/s to the position from then on. |
This is a fairly safe change that performs the reversion back AID_NONE earlier rather than waiting for attAidLossCritical to go true. AID_NONE is the most reliable mode to commence optical flow navigation from. A downside is that if too high for optical flow to work reliably, we will be without navigation for longer because when in AID_NONE the GPS checking required to commence GPS navigation is stricter. I would reconsider reverting back to AID_NONE if outside range finder range. |
Thank you very much @priseborough
I will add a check for range finder and optical flow health before reverting back to AID_NONE. |
Cool! I've been looking forward to this one! I'll probably test fly this one tomorrow. |
@priseborough, this is the kind of extra check you were thinking of? |
It did twitch a bit when it switched to optiflow, but nothing scary. Log shows it was a 3-4 degree pitch and roll. |
Thank you @RickReeser In my tests, it slipped a little when it switched to optiflow. It also slipped a little when it switched back to GPS. But copter is under control and everything is fine. |
Thank you very much for helping @rmackay9 |
I finally managed a test today and it seemed OK. It was not an exhaustive test but I did disable the GPS (using the RCx_OPTION = 65) and then re-enabled it again and there weren't any sudden movements. Here is a graph of the GPS status (scale on the right) so that we can see when it's disabled and then the EKF Longitude (in red) vs GPS longitude (in green). Note that although the GPS is disabled it keeps logging it's position). Anyway, this all seems to work so I'm tempted to merge this. I would like to hear feedback from @priseborough and/or @tridge first if possible. If not I might just merge it. |
Hi @rmackay9 this is great, thank you for testing it. |
I've squashed the commits together and made a small change to replace "&" with "==" (this came up on the weekly dev call) and merged, thanks! |
Ah, the other thing that was discussed on the dev call was whether @chobitsfan would be willing to make a similar change in EKF3. No pressure though of course! thanks again! |
Thank you @rmackay9 |
fix #9919 and fix #11156
When GPS is jammed, EKF fail-safe will be triggered even a optical flow sensor is functional and ek2_flow_use = 1. In following flight, a GSP jammer is used, SV did not go above 2x FS_EKF_THRESH and neither SP or SM go above FS_EKF_THRESH. But EKF fail-safe is still triggered even optical flow is working well. EKF did not switch to optical flow.
Copter is f450 frame with pixhawk4, hereflow and sf20. This is the GPS jammer used in following test
![Picture 3](https://user-images.githubusercontent.com/19793511/66177475-26ae0d80-e694-11e9-8ef6-94fa56e89268.jpg)
2019-10-03 11-04-34.bin.gz
After apply this PR. In following flight, a GSP jammer is used and EKF switch to optical flow. Copter loiter well. EKF switch back to GPS after GPS jammer is turned off.
2019-10-03 10-52-48.bin.gz
this PR may need #12481